

function debounce(fn, time) {
    let timer = null
    return function (...args) {
        clearInterval(timer)
        time = setTimeout(() => {
            fn.apply(this, args)
        }, time)
    }
}

function trottle(fn, time) {
    let newDate = 0;
    return function (...args) {
        let nowDate = new Date.getTime()
        if (nowDate - newDate >= time) {
            fn.apply(this, args)
            newDate = new Date().getTime()
        }
    }
}


function trottle(fn, time) {
    let timer = null
    return function (...args) {
        if (!timer) {
            timer = setInterval(() => {
                fn.call(this, ...args)
                timer = null;
            }, time)
        }
    }
}